//
//  CompanyInfoVC.m
//  stone-story
//
//  Created by liu dodo on 12-9-26.
//  Copyright (c) 2012年 liu dodo. All rights reserved.
//

#import "CompanyInfoVC.h"

@interface CompanyInfoVC ()

@end

@implementation CompanyInfoVC
@synthesize photos = _photos;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    
    [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"companyinfo.jpg"]]];
    
    //按钮
    UIButton *myBtn = [[UIButton alloc]init];
    [myBtn setFrame:CGRectMake(710,570,259,49)];
    [myBtn setBackgroundImage:[UIImage imageNamed:@"photos_btn.png"] forState:UIControlStateNormal];
    [myBtn addTarget:self action:@selector(onmyBtn_Click) forControlEvents:UIControlEventTouchUpInside];
    [myBtn.titleLabel setTextColor:[UIColor blackColor]];
        
    [myBtn setTitle:@"查看公司相册" forState:UIControlStateNormal];
    [myBtn.titleLabel setFont:[UIFont boldSystemFontOfSize:20]];
    [myBtn setTitleColor:[UIColor brownColor] forState:UIControlStateNormal];
    
    [myBtn setBackgroundColor:[UIColor clearColor]];
    
    [self.view addSubview:myBtn];

}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||interfaceOrientation==UIInterfaceOrientationLandscapeRight  );
}

//店面按钮触发事件
-(void)onmyBtn_Click
{
    
   /* GotoPhotoBrowser *gotobrowser=[[GotoPhotoBrowser alloc] init];
    //MWPhotoBrowser *browser =[gotobrowser setPath:@"Documents/productPhotos/" ];
    MWPhotoBrowser *browser =[gotobrowser goToPhotoBrowserWithPath:@"Documents/productPhotos/" ];
    [self.navigationController pushViewController:browser animated:YES];*/
    
    [self goToPhotoBrowserWithPath:@"Documents/shops/shop003/"];

  
}



#pragma mark 相册部分 根据目录去到相册
-(void)goToPhotoBrowserWithPath:(NSString*)pathString 
{
    NSMutableArray *photos = [[NSMutableArray alloc] init];
    MWPhoto *photo;
    LCFileManager *lf=[[LCFileManager alloc] init];
  
    NSMutableArray *photosArray=[lf getAllPhotosWithPath:pathString];
                                 
                                 //[self getAllPhotosWithPath:pathString];
    for(int i=0;i<photosArray.count;i++)
    {
        //Documents/productPhotos/
        NSString *fullPath=[pathString stringByAppendingString:[photosArray objectAtIndex:i]];
        photo = [MWPhoto photoWithFilePath:[NSHomeDirectory() stringByAppendingPathComponent:fullPath]];
        //photo.caption = @"Grotto of the Madonna";
        [photos addObject:photo];
    }
    self.photos = photos;
	MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
    browser.displayActionButton = YES;
    //browser.wantsFullScreenLayout = NO;//[browser setInitialPageIndex:2];
    [self.navigationController pushViewController:browser animated:YES];
}

#pragma mark - 相册部分 委托

- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
    return _photos.count;
}

- (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
    if (index < _photos.count)
        return [_photos objectAtIndex:index];
    return nil;
}



@end
